<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$setting.webname} - 班级管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style>
        #demo2 img {
            height: 110px;
        }
    </style>

</head>

<body class="gray-bg">
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>班级管理</h2>
        <ol class="breadcrumb">
            <li>
                <a href="{:url('Admins/admin')}">主页</a>
            </li>
            <li>
                <strong>添加班级</strong>
            </li>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加班级</h5>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal">
                        <!--标题-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">班级编号：</label>
                            <div class="col-sm-6">
                                <input type="text" placeholder="请输入班级编号，班级编号不能重复" id="classid" value="{$data.classid}"
                                       class="form-control">
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--资讯类型-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">班级类型：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="status" id="type">
                                    {foreach $list as $k=>$v}
                                    <option value="{$v.id}" {eq name="v.id" value="$data.type" }selected{
                                    /eq}>{$v.type_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--老师-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">班级老师：</label>
                            <div class="col-sm-6">
                                <input type="text" placeholder="请输班级老师姓名" id="teacher" value="{$data.teacher}"
                                       class="form-control">
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--排序-->
                        <div class="form-group" id="data_1">
                            <label class="col-sm-2 control-label">开班时间-毕业时间：</label>
                            <div class="col-sm-4 nput-group date">
                                <div class="input-daterange input-group" id="datepicker">
                                    <input type="text" class="input-sm form-control" name="start" id="start"
                                           value="{$data.start_time|date='Y-m-d',###}" placeholder="选择开班时间"/>
                                    <span class="input-group-addon">到</span>
                                    <input type="text" class="input-sm form-control" name="end" id="end"
                                           value="{$data.end_time|date='Y-m-d',###}" placeholder="预计毕业时间"/>
                                </div>
                            </div>
                            <div class='col-sm-6'></div>
                        </div>
                        <!--状态-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-4">
                                {eq name="data.status" value="3"}
                                <select class="form-control m-b" name="status" id="status">
                                    <option value="3">毕业</option>
                                </select>
                                {else /}
                                <select class="form-control m-b" name="status" id="status">
                                    <option {eq name="data.status" value="1" } selected {/eq} value="1">待上课</option>
                                    <option {eq name="data.status" value="2" } selected {/eq} value="2">上课中</option>
                                    <option {eq name="data.status" value="3" } selected {/eq} value="3">毕业</option>
                                </select>

                                {/eq}
                            </div>
                            <div class='col-sm-6'></div>
                        </div>
                        <!--确认-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-info btn-sm btn-block" id="save"> 保存</button>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="/public/static/admin/layui/layui.js"></script>
<script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Data picker -->
<script src="/public/static/admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<!-- 自定义js -->
<script src="/public/static/admin/js/content.js?v=1.0.0"></script>
<script src="/public/static/admin/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
<script>
    $("#status option[value='{$data.status}']").prop("selected", true);
    layui.use('upload', function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer, upload = layui.upload; //独立版的layer无需执行这一句
        var status = '{$data.status}';


        $("#save").click(function () {
            if (status != 3 && $("#status").val() == 3) {
                //询问框
                layer.confirm('班级毕业向学员颁发证书！请检查是否已经将所有学生的信息补充完成', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.post("{:url('Myclasss/toUpdate')}", {
                        classid: $("#classid").val(),
                        type: $("#type").val(),
                        teacher: $("#teacher").val(),
                        status: $("#status").val(),
                        start_time: $("#start").val(),
                        end_time: $("#end").val(),
                        id: '{$data.id}',
                        old_status :'',
                    }, function (data) {
                        top.layer.msg(data.msg, {time: 2000,shade:0.5}, function () {
                            if (data.url) {
                                window.location.href = data.url;
                            }
                        });
                    });
                });
            } else {
                $.post("{:url('Myclasss/toUpdate')}", {
                    classid: $("#classid").val(),
                    type: $("#type").val(),
                    teacher: $("#teacher").val(),
                    status: $("#status").val(),
                    start_time: $("#start").val(),
                    end_time: $("#end").val(),
                    id: '{$data.id}',
                    old_status :3
                }, function (data) {
                    top.layer.msg(data.msg, {time: 2000,shade:0.5}, function () {
                        if (data.url) {
                            window.location.href = data.url;
                        }
                    });
                });
            }
        });
    });
    $(".check").click(function () {
        if ($(this).attr('class') == "fa fa-square-o check") {
            $(this).attr('class', "fa fa-check-square-o check");
        } else {
            $(this).attr('class', "fa fa-square-o check");
        }
    });
    $(function () {
        $("#datepicker").datepicker({
            language: "zh-CN",
            autoclose: true,//选中之后自动隐藏日期选择框
            clearBtn: true,//清除按钮
            todayBtn: false,//今日按钮
            format: "yyyy-mm-dd"//日期格式，
        });
    });
</script>
<!-- SUMMERNOTE -->
<script src="/public/static/admin/js/plugins/summernote/summernote.min.js"></script>
<script src="/public/static/admin/js/plugins/summernote/summernote-zh-CN.js"></script>
<script>
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });
</script>


</body>
</html>
